import time

from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By

# 1.创建浏览器驱动对象
driver=webdriver.Chrome()
# 2.通过get方法获取网页
driver.get("http://localhost:8081/regA.html")
ele_name=driver.find_element(By.ID,"userA")
ele_name.send_keys("admin1")
time.sleep(2)
ele_name.send_keys(Keys.BACKSPACE)
# 全选
ele_name.send_keys(Keys.CONTROL,"a")
time.sleep(2)
ele_name.send_keys(Keys.CONTROL,"c")
time.sleep(2)
ele_pwd=driver.find_element(By.ID,"passwordA")
ele_pwd.send_keys(Keys.CONTROL,"v")
print(ele_pwd.get_attribute("value"))
time.sleep(2)
if ele_pwd.get_attribute("value")=="admin":
    print("通过")
else:
    print("失败")
# 4.关闭浏览器对象
driver.quit()  # 关闭浏览器